package cn.lysj.framework.config.controller;

import cn.lysj.framework.base.BaseController;
import cn.lysj.framework.common.CommonConstant;
import cn.lysj.framework.common.annotation.CurrentUser;
import cn.lysj.framework.common.domain.User;
import cn.lysj.framework.common.utils.pagination.PageVo;
import cn.lysj.framework.common.utils.web.ParamUtil;
import cn.lysj.framework.common.utils.web.Resp;
import cn.lysj.framework.common.validate.annotation.Validator;
import cn.lysj.framework.config.domain.Config;
import cn.lysj.framework.config.domain.OrderNote;
import cn.lysj.framework.config.service.OrderNoteService;
import cn.lysj.framework.foodv2.domain.FoodType;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author zwj
 * @description 订单备注控制层
 * @create 2018-12-18 11:53:47
 **/
@Slf4j
@RestController
@Api(description = "订单备注管理接口")
@RequestMapping("/order_note")
public class OrderNoteController extends BaseController<OrderNote> {

    @Resource
    private OrderNoteService orderNoteService;

    @Override
    public OrderNoteService getService() {
        return orderNoteService;
    }

    @GetMapping("/list_rewrite")
    public Resp list(@CurrentUser User user, OrderNote orderNote, PageVo pageVo) {
        orderNote.setStoreId(user.getStoreId());
        return new Resp(orderNoteService.list(orderNote, pageVo));
    }

    @PostMapping("/save_rewrite")
    public Resp save(OrderNote orderNote, @CurrentUser User user) {
        if (ParamUtil.isBlank(orderNote.getName())) {
            return new Resp(Resp.PARAM_ERROR, "内容不能为空");
        }
        orderNote.setStoreId(user.getStoreId());
        orderNote.setName(orderNote.getName());
        orderNoteService.save(orderNote);
        return new Resp("添加成功!");
    }

}
